<?                                                  
$find_name    = $_POST['super_param'];    
$find_field   = $_POST['super_field'];    
$find_filter  = $_POST['super_filter'];    
                                                            
        echo "<title>" . APPLICATION_NAME . " - Advanced Search</title>";                                                                                                                                                                                                        
        echo "<style>\n td {font:7pt verdana} \n</style>";                                                                                                                                                                                                        
        echo "<body style='border:solid 1px #ffffff'>";    
	    echo "<form action='" . $href . "?" . $qs . "' method='post'>";                                                                    
        if (isset($_POST['super_param']))                                                            
        {                               
            $rtg       = $_POST['rtg'];                                                    
            $rti       = $_POST['rti'];                                                    
            $rtx       = $_POST['rtx'];                                                    
            $groups    = $_POST['super_group'];                                                    
            $group     = array_pop ($groups);                                                                                           
            if (count($groups) > 0)                                                                                       
            {                           
                echo "<img align='absmiddle' src='loading.gif'>Looking on <a href='".$href."?g=".$group."'>" . $group . "</a> for '" . $find_name . "'<br>";                     
            }                  
        }                                                                                                                                                                                               
                                                        
        if (isset($_POST['super_param']))                                                            
        {                             ;                                                    
                                                                                                                                                                                                                                                                                                                                                                         
            $nntp      = group_lookup ($user, $pass, $group );                                                                                                                                                                                                                                                                                                   
            $first     = substr($find_name,0,1);                                                                                                                                                                                                                                                                                          
            $find_param = "[" . strtoupper($first) . strtolower($first) . "]" . substr($find_name,1);                                                                                                                                                                                                  
            $result=$nntp->search_newsgroup(1, "*" . $find_param . "*", "subject", 2, 100, true);                                                                                                                                 
			echo "<img src='images/msdn.jpg'>&nbsp;Advanced Search<hr noshade>";          
			echo "<input name='super_param' value='" . $find_name . "' type='hidden'>";                                    
            echo "<table cellspacing='0'> \n";                                                                                                                                                                                                                                                                                         
            if (count($result["articles"]) > 0)                                                                                                                                                                                                                                                                                          
            {                                                                                                                                                                                                                                                                                          
                foreach ($result["articles"] as $article)                                                                                                                                                                                                                                                                                          
                {                                                                                                                                                                                                                                                                                          
                    $id=$article->nntp_message_id;                                               
                    $sj=htmlentities( trim($article->subject) );     
					$us=$href . "?message_id=" . $id . "&art_group=" . $group . "&" . $nntp_server . "&a=slide";
					if (preg_match(REGEX_MASK_MEDIA, $article->subject, $media_map))
					{
					    $us=$href . "?nzb=" . $id . "&art_group=" . $group . "&" . $nntp_server . "&sub=nzb";         
					}                                
                    echo "<tr>";                                                                                                                                                                                                                                                                                         
                    echo "  <td>";                                                                                                                                                                                                                                                                                          
                    echo "<input type='checkbox' name='rtx[]' value=\"" . $sj . "\" checked>";                                                                                                                                                                                                                                                                                         
                    echo "</td> \n";                                                                                                                                                                                                                                                                                          
                    echo "  <td title=\"" . $sj . "\" nowrap>";                                                                                                                                                                                                                                                                                          
                    echo "<a alt=\"" . $sj . "\" href='" . $us . "'";                                                                                                                                                                                                                                                                                         
                    echo " target='_blank'>" . mid_str (htmlentities( $article->subject ), 75) . "</a></td> \n";                                                                                                                                                                                                                                                                                          
                    echo "  <td nowrap>" . mid_str($group, 50) . "</td> \n";                                                                                                                                                                                                                                                                                          
                    echo "  <td>$id</td> \n";                                                                                                                                                                                                                                                                                          
                    echo "  <input type='hidden' name='rtg[]' value=\"" . $group . "\"> \n";                                                                                                                                                                                                                                                                                         
                    echo "  <input type='hidden' name='rti[]' value=\"" . $id . "\"> \n";                                                                                                                                                                                                                                                                                         
                    echo "</tr> \n";                                                                                                                                                                                                                                                                                         
                }                                                                                                                                                                                                                                                                                       
            }                                                                                                                                                                                                                                                                                          
            else                                                                                                                                                                                                                                                                                          
            {                                                                                                                                                                                                                                                                                          
                 print "No matching articles found<br>";                                                                                                                                                                                                                                                                                          
            }                                                                                                                                                                                                                                                                                       
            for ($e=0;$e<count($rti);$e++)                                                                                                                                                                                                                                                                                          
            {                                          
                $id=$rti[$e];                                               
                $gr=$rtg[$e];                                               
                $subject=stripslashes($rtx[$e]);                                               
                $sj=htmlentities( trim($subject) );       
				$us=$href . "?message_id=" . $id . "&art_group=" . $gr . "&" . $nntp_server . "&a=slide";
				if (preg_match(REGEX_MASK_MEDIA, $subject, $media_map))
				{
					$us=$href . "?nzb=" . $id . "&art_group=" . $gr . "&" . $nntp_server . "&sub=nzb";         
				}                                                                        
                echo "<tr bgcolor='yellow'>";                                                                                                                                                                                                                                                                                         
                echo "<td>";                                                                                                                                                                                                                                                                                          
                echo "<input type='checkbox' name='rtx[]' value=\"" . htmlentities( trim($subject) ) . "\" checked>";                                                                                                                                                                                                                                                                                         
                echo "</td> \n";                                                                                                                                                                                                                                                                                          
                echo "  <td title=\"" . $sj . "\" nowrap>";                                                                                                                                                                                                                                                                                          
                echo "<a alt=\"" . $sj . "\" href='" . $us . "'";                                                                                                                                                                                                                                                                                         
                echo " target='_blank'>" . mid_str (htmlentities( $subject ), 75) . "</a>";                                                                                                                                                                                                                                                                                          
                echo "</td> \n";                                                                                                                                                                                                                                                                                          
                echo "  <td nowrap>" . mid_str($gr, 50) . "</td> \n";                                                                                                                                                                                                                                                                                          
                echo "  <td>$id</td> \n";                                                                                                                                                                                                                                                                                          
                echo "  <input type='hidden' name='rtg[]' value=\"" . $gr . "\"> \n";                                                                                                                                                                                                                                                                                         
                echo "  <input type='hidden' name='rti[]' value=\"" . $id . "\"> \n";                                                                                                                                                                                                                                                                                         
                echo "</tr> \n";                                                                                                                                                                                                                                                                                         
            }                                          
            echo "</table>";                                                                                         
            if (count($groups) > 0)                                                                                       
            {                                                                                       
                foreach ($groups as $name)                                                                                       
                {                                                                                       
                    if (trim($name)!="") echo "<input type='checkbox' name='super_group[]' checked value='$name'>$name<br>";                                                                                       
                }                                     
                echo script_block ("window.onload=function() { document.forms[0].submit(); }");                                                                 
            }                                                                  
        }                                                            
        else                                                                                                                                                                                                       
        {                                                                                                                                                                                                          
			echo "<table>";                                                                                                                                                                                                        
			echo " <tr>";                                                                                                                                                                                                        
			echo "  <td valign='top'><img src='images/msdn.jpg'>&nbsp;Advanced Search<hr noshade>";                                                                                                                                                                                                        
			echo "   <table>";                                                                                                                                                                                                        
			echo "    <tr>";                                                                                                                                                                                                        
			echo "     <td>";                                                                                                                                                                                                        
			echo "      Find: ";                                                                                                                                                                                                        
			echo "     </td>";                                                                                                                                                                                                        
			echo "     <td>";                                                                                                                                                   
			echo "      <input size='65' name='super_param' value='" . $find_name . "' type='text'>";                                                                                                                                                                                                        
			echo "     </td>";                                                                                                                                                                                                        
			echo "    </tr>";                                                                                                                                                                                                                                                                                                                                                     
			echo "   </table>";                                                                                                                                                                                                        
			echo "  </td>";                                                                                                                                                                                                        
			echo "  <td>";                                                                                                                                                                                                          
			echo "  </td>";                                                                                                                                                                                                        
			echo " </tr>";                                                                                                                                                                                                        
			echo " <tr>";                                                                                                                                                                                                        
			echo "  <td>";                                                   
			echo "<div style='height:275px;width:475px;overflow:auto;border:solid 1px silver'>";                                                      
            echo "Enter all or part of the article name you want to search for and click the Search button.<br>";                                                            
            if ( $dom = domxml_open_mem( stripslashes($editor) ) )                                                                                            
            {                                                                                                     
                $groups = $dom->get_elements_by_tagname ( "group" );                                                                                         
                foreach ($groups as $group)                                                                                       
                {                                                                                       
                    $name = $group->get_attribute ("name");                                                                                          
                    if (trim($name)!="") echo "<input type='checkbox' name='super_group[]' checked value='$name'>$name<br>";                                                                                       
                }                                                                                                     
            }                                                     
			echo "</div>";                                                       
			echo "  </td>";                                                                                                                                                                                                        
			echo "  <td valign='top'>";                                                                                                                                                                                                      
			echo "   <div align='center' width='100%' style='margin:5px'>     ";                                                                                                                                                                                                   
			echo "    <input type='submit' " . (isset($_POST['super_param']) ? "disabled" : "") . " style='width:75;margin:1px' value='Search'><br>    ";                                                                                                                                                                                                    
			echo "    <input type='button' style='width:75;margin:1px' value='Cancel' onclick='self.close()'> ";                                                                                                                                                                                                       
			echo "   </div>";                                                                                                                                                                                                       
			echo "  </td>";                                                                                                                                                                                                        
			echo " </tr>";                                                                                                                                                                                                        
			echo " <tr>";                                                                                                                                                                                                        
			echo "  <td>";                                                                                                                                                                                                        
			echo "  </td>";                                                                                                                                                                                                        
			echo "  <td></td>";                                                                                                                                                                                                        
			echo " </tr>";                                                                                                                                                                                                        
			echo "</table>";                                                             
        }                                                                                                                                                                                                                 
		echo "</form>";                                                                                                                                                                                                     
        echo "</body>";                                                                  
exit;                                                                
?>